package springIOC.IOC_XML.controller;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Controller;
import springIOC.IOC_XML.config.ConfigClass;
import springIOC.IOC_XML.service.UserService;

import javax.annotation.Resource;

@Controller("controller2")
public class Control2 {

    @Resource(name="userService")
    private UserService service;

    public UserService getService() {
        return service;
    }

    public void setService(UserService service) {
        this.service = service;
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigClass.class);
        Control2 con=context.getBean("controller2", Control2.class);
        System.out.println(con.getService().findUserByID(1001));
        System.out.println("--------------------------------------------------------------------------------------------");
        System.out.println(con.getService().findUserByName("jerry"));
    }
}
